// 添加收货地址
// POST
// /member/address
// isDefault:是否为默认，1为是，0为否 ，注意：此处按照接口实现

import type { AddAddressData, AddAddressParams, AddressItem } from '@/types/add'
import { http } from '@/utils/http'

export const addAddressAPI = (data: AddAddressParams) => {
  return http<AddAddressData>({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

/**
 * 获取收货地址列表
 */
export const getMemberAddressAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}

/**
 * 删除收货地址
 * @param id 地址id(路径参数)
 */
export const deleteMemberAddressByIdAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}

/**
 * 获取收货地址详情
 * GET
 * /member/address/{id}
 */
export const getMemberAddressByIdAPI = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

/**
 * 修改收货地址
 * @param id 地址id(路径参数)
 */
export const editMemberAddressByIdAPI = (id: string, data: AddAddressParams) => {
  return http<AddAddressData>({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}
